package com.domain.VO;

import com.domain.DO.FlightClass;
import com.domain.pojo.FlightClassLevel;
import com.domain.pojo.SeatStation;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * @author 大忽悠
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class FlightOrderVo {
    /**
     * 乘客名
     */
    private String buyName;

    /**
     * 乘客对应的用户id
     */
    private Integer userId;

    /**
     * 身份证账号
     */
    private String peopleCard;

    /**
     * 座位偏好: 0是窗口,1是过道,2是中间
     */
    private Integer seatHobby;

    /**
     * 舱位类型,1是商务舱,0是经济舱,默认为经济舱
     */
    private Integer degree;

    /**
     * 班次号
     */
    private Integer flightClassId;

    public void seatNumberCheck(FlightClass flightClass) {
        FlightClassLevel.seatNumCheck(degree,flightClass);
    }

    /**
     * 如果没有适合用户选择的座位号,那么就随机选择一个
     * @param flightClass
     * @return 返回用户最终购买的座位号
     */
    public Integer careUserSeatHobby(FlightClass flightClass) {
        String seatInfo = flightClass.getSeatInfo();
        Integer seatSeq=SeatStation.choseOneSeatByStation(seatInfo,seatHobby);
        if(seatSeq==null){
            seatSeq=SeatStation.choseByRandom(seatInfo);
        }
        return seatSeq;
    }

    public Integer getDegree() {
        return degree==null?0:degree;
    }
}
